<%@page import="com.wanmait.cookBook.vo.Topic"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="com.wanmait.cookBook.vo.Pager"%>
<%@page import="com.wanmait.cookBook.vo.Comment"%>
<%@page import="com.wanmait.cookBook.vo.FoodDetails"%>
<%@page import="com.wanmait.cookBook.vo.Cook"%>
<%@page import="java.util.ArrayList"%>
<%@page import="com.wanmait.cookBook.vo.Userinfo"%>
<%@page import="com.wanmait.cookBook.vo.Diary"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
 <%String path = request.getContextPath(); %>
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>爱下厨·日志</title>
<meta http-equiv="mobile-agent" content="format=xhtml; url=https://m.meishichina.com/article/224252/">
<link rel="alternate" media="only screen and (max-width: 640px)" href="https://m.meishichina.com/article/224252/">
<meta name="renderer" content="webkit">
<link rel="shortcut icon" href="//static.meishichina.com/v6/img/lib/f.ico"/>
<link rel="apple-touch-icon" href="//static.meishichina.com/v6/img/lib/wapico.png" />
<link rel="stylesheet" type="text/css" href="//static.meishichina.com/v6/css/lib/all.css?v1=8">
<link rel="stylesheet" type="text/css" href="//static.meishichina.com/v6/css/lib/cms.css?v1=2018-10-09">
<script type="text/javascript" src="//static.meishichina.com/v6/js/lib/dfp-content-5.js"></script>
    <script type="text/javascript" src="<%=path%>/front/js/jquery-3.5.0.min.js"></script>
 
 <meta name="renderer" content="webkit">
<meta http-equiv="mobile-agent" content="format=xhtml; url=https://m.meishichina.com/recipe/556348/">
<link rel="alternate" media="only screen and (max-width: 640px)"  href="https://m.meishichina.com/recipe/556348/">
<link rel="shortcut icon" href="https://static.meishichina.com/v6/img/lib/f.ico"/>
<link rel="apple-touch-icon" href="https://static.meishichina.com/v6/img/lib/wapico.png" />
<link rel="stylesheet" type="text/css" href="https://static.meishichina.com/v6/css/lib/all3.css?v1=2017-10-24">
<link rel="stylesheet" type="text/css" href="https://static.meishichina.com/v6/css/app/newrecipe/recipe_newone.css?v1=2019-05-07">
<link rel="stylesheet" type="text/css" href="https://static.meishichina.com/v6/css/lib/comment.css?v1=2015-07-16">
<script type="text/javascript" src="https://static.meishichina.com/v6/js/lib/dfp-content-5.js"></script>  




<meta http-equiv="mobile-agent" content="format=xhtml; url=https://m.meishichina.com/pai/1137470/">
<link rel="alternate" media="only screen and (max-width: 640px)"  href="https://m.meishichina.com/pai/1137470/">
<link rel="shortcut icon" href="https://static.meishichina.com/v6/img/lib/f.ico"/>
<link rel="apple-touch-icon" href="https://static.meishichina.com/v6/img/lib/wapico.png" />
<link rel="stylesheet" type="text/css" href="https://static.meishichina.com/v6/css/lib/all.css?v1=13">
<link rel="stylesheet" type="text/css" href="https://static.meishichina.com/v6/css/app/suipai/pai2.css?v1=2018-10-13" />
<link rel="stylesheet" type="text/css" href="https://static.meishichina.com/v6/css/lib/comment.css?v1=2015-07-16">
<script type="text/javascript" src="https://static.meishichina.com/v6/js/lib/dfp-content-7.js"></script>


 
<style>
.comment-post-tools .comment-btn{background: #ff6767}
.comment-nav{border-left: 2px solid #ff6767;}
</style>
<!-- 弹窗样式 -->
<link rel="stylesheet" type="text/css" href="https://www.huangwx.cn/css/sweetalert.css">
<script type="text/javascript" src="https://www.huangwx.cn/js/sweetalert-dev.js"></script>
</head>
<body>
<div>
	<jsp:include page="/front/head.jsp"></jsp:include>
</div>
<div class="logo_wrap2" style="margin-top:-40px;">
<div class="logo_inner left">
<a href="" title="美食天下">美食天下</a>
</div>
<div class="logo_current left">
<h1><a href="" title="饮食健康">饮食健康</a></h1>
</div>


<!-- 搜索栏 -->
<div class="logo_search right">
<div class="searchBox J_search">
		<form method="post" action="<%=path%>/DiaryServlet?action=getAllDiary">
			<input type="submit" value="搜索" class="search_Btn J_searchBTN right" >
			<input type="text" style="width:100px;" name="context"  class="search_Text J_searchTxt right">
		</form>
</div>
</div>
<!--  -->
<!--搜索栏同行-->
<div class="logo_nav">
<a title="日志首页" class="on"  href="<%=path%>/DiaryServlet">日志首页<i></i><b></b></a>
<a title="话题" class=""  href="<%=path%>/DiaryServlet">话题<i></i><b></b></a>
<a title="话题" class=""  href="<%=path%>/DiaryServlet">菜谱<i></i><b></b></a>
</div>
</div>


<div class="nav_wrap2">
<ul>
<li><a href="<%=path %>/IndexServlet" title="首页">首页</a></li>
<li><a href="<%=path %>/DiaryServlet" title="日志">菜谱</a></li>
<li><a href="<%=path %>/DiaryServlet" title="话题">话题</a></li>
<li><a href="<%=path %>/DiaryServlet" title="日志">日志</a></li>
</ul>
</div>

<div class="wrap">
<div class="w clear">
<div class="space_left">
<div class="main">



 <!-- ----------------------列出详细信息—————————————————————— -->
 		<%Diary diary = (Diary)request.getAttribute("diary");%>
 		<!-- 标题 -->
		 		<h1>
					<a class="arTitle" title="<%=diary.getDiaryName() %>">
						<%=diary.getDiaryName() %>						
					</a>
				</h1>				
		<!-- 时间 -->
				<div id="arInfo">
				<% SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
				  String time = format.format(diary.getPublishTime()); %> 
		       <%=time %>
				
				<span style="margin-left:350px">  <a> <img width="40px" height="40px" style="border-radius:30px;" src="<%=path %>/front/userImages/<%=diary.getUserinfo().getUserFace() %>"></a></span>  
				<span style="margin-left:10px">	<a href=""><font size="4"><%=diary.getUserinfo().getUserName() %></font> </a></span>              
						
				</div>
				
				
		<!-- 内容 -->	
				<div class="content 224252">
				<p><%=diary.getDiaryContext() %></p>
				</div>
	
	

<!-- 点赞收藏 -->
	  
<div class="recipeArction mt10 clear">
<ul class="collect_da"style="margin:auto;padding:0;">
<li class="lik" style="margin-left:170px;"><a diaryId=<%=diary.getId() %> title="点赞" href="javascript:void(0);" id="likeThis" class="J_lik"><i ></i><span id="likeCount">人点赞<span></span></a></li>
<li class="fav"><a title="收藏" diaryId=<%=diary.getId() %>  href="javascript:void(0);" id="collectThis" class="J_fav" ><i></i><span id="collectCount">人收藏</span></a></li>
<li style="width:1px;border-right: 1px solid #ddd; height: 30px; margin: 2px 10px; overflow: hidden;"></li>
</ul>			 
</div>
<div class="goindex"><a target="_blank" href="<%=path%>/IndexServlet">&gt;&gt; 去首页</a></div> 	
	

<!-- 点赞事件 -->
<script type="text/javascript">

$(function(){
	$("#likeThis").click(function(){
		
		//先判断用户是否登录
		var loginuser = "<%= (Userinfo)session.getAttribute("loginuser")%>";
		if(loginuser=="null")
		{
			location.href  = "<%=path%>/front/login.jsp";			
		}
		else
		{
			var diaryId = $("#likeThis").attr("diaryId");
	
			$.ajax({
				url:"<%=path%>/DiaryServlet",
				async:false,
				type:"post",
				data:{action:"likeDiary",diaryId:diaryId},
				success:function(mes){
					countLike();
					isLike();
				}//函数结束
			});//ajax结束
		}
		
	});//点击事件结束
})//

//点赞数
$(function(){
	countLike();
	var loginuser = "<%= (Userinfo)session.getAttribute("loginuser")%>";
	if(loginuser!="null")
		{
			isLike();
		}
	
})

function countLike()
{
	var diaryId = $("#likeThis").attr("diaryId");
	$.ajax({
		url:"<%=path%>/DiaryServlet",
		type:"post",
		data:{action:"countLike",diaryId:diaryId},
		async:false,
		success:function(mes){
			$("#likeCount").html(mes+"人点赞");
		}//
		
	});//ajax结束	
}

//加状态+√
function isLike()
{
	var diaryId = $("#likeThis").attr("diaryId");
    var content = $("#likeCount").html();
	$.ajax({
		url:"<%=path%>/DiaryServlet",
		data:{action:"isLike",diaryId:diaryId},
		type:"post",
		async:false,
		success:function(mes){
			if(mes==1)
				{
					$("#likeCount").html(content+"√");
				}
			if(mes==0)
				{
					$("#likeCount").html(content);
				}			
		}//函数结束
	});//ajax结束
}
</script>


<!-- 收藏事件 -->
<script type="text/javascript">
var diaryId = $("#collectThis").attr("diaryId");
$(function(){
	$("#collectThis").click(function(){

		//先判断用户是否登录
		var loginuser = "<%= (Userinfo)session.getAttribute("loginuser")%>";
		if(loginuser=="null")
		{
			location.href  = "<%=path%>/front/login.jsp";			
		}
		else
		{
			$.ajax({
				url:"<%=path%>/DiaryServlet",
				async:false,
				type:"post",
				data:{action:"collectDiary",diaryId:diaryId},
				success:function(mes){
					countCollect();
					isCollect();
				}//函数结束
			});//ajax结束
		}
			
	});//给收藏增加点击事件
})




//收藏数
$(function(){
	countCollect();
	var loginuser = "<%= (Userinfo)session.getAttribute("loginuser")%>";
	if(loginuser!="null")
		{
			isCollect();
		}
	
})
function countCollect()
{
	$.ajax({
		url:"<%=path%>/DiaryServlet",
		type:"post",
		data:{action:"countCollect",diaryId:diaryId},
		async:false,
		success:function(mes){
			$("#collectCount").html(mes+"人收藏");
		}//
		
	});//ajax结束	
}


//加状态+√
function isCollect()
{
	var diaryId = $("#collectThis").attr("diaryId");
    var content = $("#collectCount").html();
	$.ajax({
		url:"<%=path%>/DiaryServlet",
		data:{action:"isCollect",diaryId:diaryId},
		type:"post",
		async:false,
		success:function(mes){
			if(mes==1)
				{
					$("#collectCount").html(content+"√");
				}
			if(mes==0)
				{
					$("#collectCount").html(content);
				}			
		}//函数结束
	});//ajax结束
}
</script>
	
<!-- -----------------------评论--------------------------------- -->
<!--------评论在线编辑器 ---------->
<div style="clear:both;">
	<textarea id="content"  name="content" ></textarea>
	<input type="button" id="addComment" value="发布评论" style="margin:10px 0; margin-left:0px;">
</div>


<!-- 将文本域的内容替换成在线编辑器 -->
<!-- 先导入config.js 是在线编辑器的配置文件-->
<script type="text/javascript" src="<%=path %>/front/ueditor3/ueditor.config.js"></script>
<!-- all.js是在线编辑器的代码 --><!-- all.js使用了config.js文件中的内容 -->
<script type="text/javascript" src="<%=path %>/front/ueditor3/ueditor.all.js"></script>

<!-- 调用导入的all.js文件中的方法将文本域替换成在线编辑器 -->
<script type="text/javascript">
	$(function(){
		
		var items = {
				initialFrameWidth:600,//在线编辑器的宽度和高度
				initialFrameHeight:170,
				toolbars:[['source','bold','|','underline','forecolor','map','emotion','undo','redo','indent','insertimage','map',],['simpleupload','forecolor','backcolor','scrawl','justifyleft', ]]//工具栏 有2行
					}
		editor = UE.getEditor("content",items);
		//实现文件上传 将jsp->lib->5个文件复制到web-INF->lib文件夹下
		//修改config.json  imageUrlPrefix//项目名称 imagePathFormat//文件夹
		//在线编辑器中的图片上传到了tomcat中的commentImage文件夹中
	});
</script>
  <!-- 提交评论事件 -->
<script type="text/javascript">
	$(function(){
		$("#addComment").click(function(){
			 var loginuser = "<%=(Userinfo)session.getAttribute("loginuser")%>";
			 var diaryId = "<%=diary.getId()%>";
			 var content = editor.getContent();
			 
			if("null"==loginuser)//js是否为空比较 "null"
			{
				location.href  = "<%=path%>/front/login.jsp";
				return;
			}
			if(content=="")
			{
			 	swal("评论不能为空呦~");	
			}
			if(content!="")
			{
				$.ajax({
					url:"<%=path%>/CommentServlet",
					async:false,
					data:{diaryId:diaryId,content:content,action:"addDiaryComment"},
					type:"post",
					success:function(mes)
						{
							$("#commentDiary").html(mes);
						}
				});//ajax结束
			}
			
		});//点击事件结束
	})
</script>
<!-- ------------------- -->

<div id="commentDiary">
<!-- 评论区 -->
<div class="ui_title_wrap clear" style="margin-bottom:20px">

<!-- 获取评论数量 -->
<% int count = (int)request.getAttribute("count"); %>
<h3 class="on"><a order="hot" data="0" page="2" href="">|最新评论</a></h3>
<h3 class=""><a order="hot" data="0" page="2" href="">(<%=count%>条)</a></h3>
</div>	
		
		<% ArrayList<Comment> getAllCookComment = (ArrayList<Comment>)request.getAttribute("getAllDiaryComment"); %>
		<%if(count==0)
		{
		%>
			<div id="arInfo" style="margin-top">						
			  	 <span ><font size="4">快来发布第一条评论吧~</font></span>  				            						
			 </div>		
		<%			
		}%>
		<%for(Comment comment:getAllCookComment)
		{
		%>
		
				<!-- 时间 -->
				
					<div id="arInfo" style="margin-top">						
						 <a> <img width="40px" height="40px" style="border-radius:30px;" src="<%=path%>/front/userImages/<%=comment.getFromUser().getUserFace()%>"></a>
						 <span ><a href=""><font size="4"><%=comment.getFromUser().getUserName() %></font> </a></span>  
							<% SimpleDateFormat formatt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
				 			 String timex = formatt.format(comment.getCommentTime());%> 
		      				 <%=timex %>
						<span style="margin-right:10px"><a commentId="<%=comment.getId()%>"  class="replay" href="javascript:void(0)">回复</a></span>			            						
					</div>		
				<!-- 内容 -->	
				<%if(comment.getToUser().getUserName()!=null)
				{
				%>
					<div class="content 224252">
						<p><font size="3"><%=comment.getFromUser().getUserName()%>回复<%=comment.getToUser().getUserName()%>:<%=comment.getCommentContent() %></font></p>
					</div>
				<% 	
				}
				%>
				<%if(comment.getToUser().getUserName()==null) 
				{
				%>
						<div class="content 224252">
							<p><font size="3"><%=comment.getCommentContent() %></font></p>
						</div>
				<% 
				}
				%>	
					<div class="onlineReplay" style="display:none">
								<div style="clear:both;">
									<textarea id="<%=comment.getId() %>"  name="replayContent"  ></textarea>
									<input commentId=<%=comment.getId() %> toUser=<%=comment.getFromUser().getId() %> type="button" class="addReplay" value="回复" style="margin:10px 0; margin-left:0px;">									
								</div>							
							</div>
							<hr>
		<% 	
		} 
		%>
	

	<!-- 给回复增加事件 -->
<script type="text/javascript">
$(function(){
	$(".replay").click(function(){
		$(".onlineReplay").css("display","none");
		var commentId = $(this).attr("commentId");
		$(this).parent().parent().next().next().css("display","block");
		//替换在线编辑器
		
		var items = {
				initialFrameWidth:600,//在线编辑器的宽度和高度
				initialFrameHeight:170,
				toolbars:[['source','bold','|','underline','forecolor','map','emotion','undo','redo','indent','insertimage','map',],['simpleupload','forecolor','backcolor','scrawl','justifyleft', ]]//工具栏 有2行
					}
		ReplayEditor = UE.getEditor(commentId,items);
		
	
	});//点击回复事件结束
})

 //发布回复
 $(function(){
	 $(".addReplay").click(function(){
		 var loginuser = "<%=(Userinfo)session.getAttribute("loginuser")%>";
		 var diaryId = "<%=diary.getId()%>";
		 var content = ReplayEditor.getContent();
		 var toUser = $(this).attr("toUser");
		if("null"==loginuser)//js是否为空比较 "null"
		{
			location.href  = "<%=path%>/front/login.jsp";
			return;
		}
		if(content=="")
		{
		 	swal("评论不能为空呦~");	
		}
		if(content!="")
		{
			$.ajax({
				url:"<%=path%>/CommentServlet",
				async:false,
				data:{diaryId:diaryId,content:content,action:"diaryReplay",toUser:toUser},
				type:"post",
				success:function(mes)
					{
						$("#commentDiary").html(mes);
					}
			});//ajax结束
		}	 
	 });//点击按钮结束
 })
</script>	
<!-- -------------------分页------------------- -->
				<div class="ui-page mt20"  id="pagerpager">
				<div class="ui-page-inner" id="pagerxx">	
					<% Pager pager = (Pager)request.getAttribute("pager"); %>
					<a href="<%=path%>/DiaryServlet?action=showDiary&pageNo=<%=pager.getPageNo()-1%>&diaryId=<%=diary.getId()%>">上一页</a>
				
					<% for(int i =1;i<=pager.getPageCount();i++)
					{
					%>	
							<a class="no<%=i%>" href="<%=path%>/DiaryServlet?action=showDiary&diaryId=<%=diary.getId()%>&pageNo=<%=i%>"><%=i%></a>
					<%
					}
					%>				
						<a href="<%=path%>/DiaryServlet?action=showDiary&pageNo=<%=pager.getPageNo()+1%>&diaryId=<%=diary.getId() %>">下一页</a>	
				</div>
				</div>
		</div>		
<!-- 改变颜色的事件 -->
<script type="text/javascript">
	$(function(){
		$(".no<%=pager.getPageNo()%>").css("color","red");
	})
</script>






<!-- 距离底部的边距 -->
<div id="comment_top">
<script type="text/javascript" src="//ftic.qifake.com/fasjbjbbj.js"></script>
</div>
</div>
</div>

<!-- ——————————————————————侧边栏—————————— -->
<div class="space_right">
<div class="ui_title mt20 clear">
<div class="ui_title_wrap">
<h3 class="on">热门菜谱</h3>
<a title="菜谱" href="<%=path %>/ShowAllCookServlet" class="right" target="_blank">更多</a>
</div>
</div>
<!-- 收藏最多的18个菜谱名 -->
<div class="gongxiao_r mt10">
			<% ArrayList<Cook> getMostCollectCook = (ArrayList<Cook>)request.getAttribute("getMostCollectCook"); %>
			<% for(Cook cook:getMostCollectCook) 
			{
			%>
				<div>
				<a title="" href="<%=path %>/ShowPersonalCookServlet?cookId=<%=cook.getId()%>" target="_blank"><%=cook.getCookName()%></a>
				</div>	
			<%				
			}
			%>
</div>



<div class="ui_title mt20 clear">
	<div class="ui_title_wrap">
		<h3 class="on">热门话题</h3>
		<a target="_blank" href="<%=path %>/TopicServlet" class="right">更多</a>
	</div>
</div>

<div class="zhen_r_list clear">
<ul>			
					<%ArrayList<Topic> getTopTopic =(ArrayList<Topic>)request.getAttribute("getTopTopic");%>
		<%for(Topic topics:getTopTopic){%>		
						                <li>
					<a href="<%=path %>/ShowDetailedTopicServlet?action=<%=topics.getId() %>" target="_blank" class="pic">
						<img src="<%=path %>/front/topicImages/<%=topics.getTopicImage() %>"  class="imgLoad">
					</a>
										<p><a  href="" target="_blank"><strong><%=topics.getTopicName() %></strong></a></p>
										<p>
					<a href="<%=path %>/ShowDetailedTopic?action=<%=topics.getId() %>" target="_blank"><%=topics.getContext() %></a>
					</p>
					</li>
					
		<% } %>			
</div>








<!-- 最新6个菜谱 -->
<div class="ui_title mt20">
<div class="ui_title_wrap cleat">
<h3 class="on">最新推荐</h3>
<a title="菜谱大全" class="right" href="<%=path %>/ShowAllCookServlet" target="_blank">更多</a>
</div>
</div>



<div class="timeline clear">
		<%   ArrayList<Cook> getNewFiveCook = (ArrayList<Cook>)request.getAttribute("getNewFiveCook") ;%>
		<% for(Cook cook:getNewFiveCook) 
		{
		%>
					<ul id="getRecommendNewRecipe">						
						<li class="t1" data-id="80930">
						<a target="_blank" href="<%=path %>/ShowPersonalCookServlet?cookId=<%=cook.getId() %>" class="clear">
						
									<div><b><img src="<%=path%>/front/cookFaceImage/<%=cook.getCookPicture()%>"></b>
									</div>
									<h2><%=cook.getCookName() %></h2>
									<p>
									<%for(FoodDetails foodDetails:cook.getAllFoodDetails())
										{
										%>
											<%=foodDetails.getFoodName() %>
										<% 
										}%>										
								</p>
								<span>菜谱</span>
						</a>
						</li>
					</ul>		
		<%		
		}
		%>
		
</div>


<div class="mt20" id="smnbk"></div>

</div>
</div>
</div>





				<!-- ------------------------尾不动  ---------------------------------------------------------- -->
<!--底部 -->
<div style="clear:both;">
<jsp:include page="/front/footer.jsp"></jsp:include>
</div>



</body>
</html>
    